Use the resource manager to access and use resources in kzb files. More...
#include <kanzi/core.ui/resource/resource_manager.hpp>
Classes | |
class | AcquireTask |
Load task for a group of resources. More... | |
class | FinishingQueue |
Collection of resource loading tasks that have been already been loaded by a loader thread and are waiting to be finished by the main thread. More... | |
struct | LoadTask |
Use this base class to implement the load tasks that load new resources. More... | |
Public Types | |
enum | MemoryStrategy { KeepInMemory, OptimizeMemory } |
Resource manager memory strategy. More... | |
typedef shared_ptr< LoadTask > | LoadTaskSharedPtr |
LoadTask shared pointer type. More... | |
typedef vector< LoadTaskSharedPtr > | ResourceContainer |
Container type for load tasks. More... | |
typedef kzsException(* | ProtocolHandler) (ResourceManager *resourceManager, string_view resourceURL, string_view protocol, string_view hostname, unsigned port, string_view path, void *userData, ResourceSharedPtr &out_resource, LoadTaskSharedPtr &out_loadTask) |
Type definition for the protocol handler of the load function. More... | |
typedef function< void(ResourceManager *, string_view resourceURL, string_view protocol, string_view hostname, unsigned port, string_view path, void *userData, Resource *resource)> | ProtocolResourceReloadFunction |
Type definition for the protocol handler of the reload function. More... | |
typedef vector< pair< string, KzuBinaryDirectory * > > | DirectoryContainer |
Type for the directory container. More... | |
typedef vector< pair< LoadTaskSharedPtr, ResourceLoaderThreadContext * > > | FinishingQueueContainer |
Container type for the finishing queue. Used internally. More... | |
typedef unordered_set< string > | UrlContainer |
Container type for URL set. More... | |
typedef function< void()> | AsyncAcquireFinishedCallback |
Callback function type for acquire tasks. More... | |
typedef shared_ptr< AcquireTask > | AcquireTaskSharedPtr |
AcquireTask shared pointer type. More... | |
typedef unique_ptr< KzbFile > | KzbFilePtr |
Type for a smart pointer to a KZB file. More... | |
typedef map< string, vector< KzbFilePtr > > | KzbFileDictionary |
Type for the KZB file container. More... | |
Public Member Functions | |
ResourceManager (KzcMemoryManager *memoryManager) | |
Constructor. More... | |
~ResourceManager () | |
Destructor. More... | |
void | initializeLoaderThreads (size_t threadCount, size_t maxPendingResources) |
Initializes the additional resource loader threads for the resource manager. More... | |
void | uninitializeLoaderThreads () |
Stops and removes the loader threads. After the call, all loading happens in the main thread. More... | |
void | setMaxPendingResources (size_t maxPendingResources) |
You can use this function to change the maximum number of resources that can be processed by the loading threads at the same time. More... | |
void | addDirectory (KzuBinaryDirectory *directory) |
Adds a binary directory to the resource manager to be used with the kzb protocol. More... | |
KzuBinaryDirectory * | mergeDirectory (KzuBinaryDirectory *directory) |
Merges a binary directory with another binary directory that has the same name and that already exists in the resource manager: More... | |
void | removeDirectory (KzuBinaryDirectory *directory) |
Removes a binary directory from the resource manager. More... | |
void | addKzbFile (string_view fileName) |
Opens a kzb file from the file system and adds it to the list of files. More... | |
void | addKzbFile (unique_ptr< KzbFile > kzbFile) |
Adds a kzb file to the list of files. More... | |
void | addKzbFile (ConstByteSpan data) |
Adds a memory block as a kzb file. More... | |
unique_ptr< ReadOnlyMemoryFile > | openFile (string_view url, KzbFile **kzbFile) |
Opens a handle to a resource file inside a kzb file. More... | |
KzuBinaryDirectory * | getDirectory (string_view name) const |
Gets the binary directory with the given name from the resource manager. More... | |
KzuBinaryDirectory * | addDirectoryFromFile (string_view fileName) |
Adds a binary directory from a kzb file to the resource manager, which you can then use with the kzb protocol. More... | |
KzuBinaryDirectory * | mergeDirectoryFromFile (string_view fileName) |
Loads a binary directory from a kzb file and merges it with another binary directory with the same name that already exists in the resource manager. More... | |
DirectoryContainer::const_iterator | beginDirectories () const |
Returns the iterator to the beginning of binary directories. More... | |
DirectoryContainer::const_iterator | endDirectories () const |
Returns the iterator to the end of binary directories. More... | |
void | invalidateAllGPUResources () |
Kanzi internally uses this function to set all the GPU resources to undeployed state when an application loses and recreates the GL context after a pause-resume event. More... | |
void | getMemoryUsage (size_t *out_resourceCount, size_t *out_cpuMemoryUsage, size_t *out_gpuMemoryUsage) const |
Calculates the memory usage summary for all resources. More... | |
size_t | getAcquireTaskCount () const |
Returns the number of acquire tasks that have been started with a call to acquireResourcesAsync and have not yet been completed. More... | |
size_t | getLoadQueueSize () const |
Returns the number of resource load tasks that are being processed. More... | |
Domain * | getDomain () const |
Returns the domain. More... | |
void | registerProtocolHandler (kzString protocol, ProtocolHandler handler, ProtocolResourceReloadFunction reloadFunction, void *userData) |
Registers a protocol handler for loading resources specified with the given resource URL protocol (scheme name). More... | |
void | unregisterProtocolHandler (kzString protocol) |
Unregisters the protocol handler with the given resource URL protocol (scheme name). More... | |
bool | supportsProtocolHandler (kzString protocol) const |
Checks whether the given resource URL protocol (scheme name) is registered as a protocol handler for the resource manager. More... | |
ResourceSharedPtr | acquireResource (string_view url) |
Acquires a resource associated with the given URL. More... | |
ResourceSharedPtr | tryAcquireResource (string_view url) |
Acquires a resource associated with the given URL, like acquireResource, but does not throw exceptions. More... | |
template<typename Type > | |
shared_ptr< Type > | tryAcquireResource (string_view url) |
Acquires a resource associated with the given URL and casts the resource to the given type. More... | |
template<typename Type > | |
shared_ptr< Type > | acquireResource (string_view url) |
Acquires a resource associated with the given URL and casts the resource to the given type. More... | |
void | registerResource (string_view url, ResourceSharedPtr resource) |
Associates the given URL with the resource so that the next acquireResource with the URL returns the resource. More... | |
void | registerLoadTask (string_view url, LoadTaskSharedPtr loadTask) |
Associates the given URL with the resource so that the next acquireResource with the URL completes the load task and returns the result. More... | |
void | unregisterResource (string_view url) |
Removes the association of the given URL to a resource or a load task. More... | |
ResourceSharedPtr | acquireLoadedResource (string_view url) const |
Acquires a resource associated with the given URL. More... | |
BitmapImageUniquePtr | loadImage (string_view url) const |
Loads an image from the given URL. More... | |
KzcSpline * | loadSpline (string_view url) const |
Loads a spline from the given URL. More... | |
string | getResourceURL (const Resource &resource) const |
Tries to find a URL for the given resource. More... | |
void | setDefaultMemoryStrategy (MemoryStrategy resourceReleaseStrategy) |
Sets the memory release strategy for new resources. More... | |
MemoryStrategy | getDefaultMemoryStrategy () const |
Gets the memory release strategy. More... | |
void | purge () |
Deletes unreferenced resources. More... | |
void | update () |
Processes resource manager load and deployment queues to progress the background tasks. More... | |
FinishingQueue & | getFinishingQueue () |
Gets the finishing queue for asynchronous loading tasks. More... | |
bool | processDeploymentQueueItem () |
Processes asynchronous loading tasks by deploying a single loaded GPU resource. More... | |
bool | hasDeploymentTasks () const |
Tell if deployment queue is empty. More... | |
AcquireTaskSharedPtr | acquireResourcesAsync (const UrlContainer &urls, AsyncAcquireFinishedCallback callback) |
Creates a background task that loads and deploys all resources from a set of URLs. More... | |
void | wait (AcquireTask &acquireTask) |
Blocks the execution until the async acquire task finishes and calls the callback of the task (unless it has been called already). More... | |
void | deployGPUResources () |
Kanzi internally uses this function to reload all GPU resources that have been invalidated by the pause-resume event. More... | |
void | setDomain (Domain *domain) |
Kanzi internally uses this function to set the domain of the resource manager when it creates a resource manager. More... | |
KzcMemoryManager * | getMemoryManager () const |
Returns the memory manager. More... | |
KzuBinaryFileInfo * | getBinaryFileInfo (string_view url) const |
Gets the kzb file information for a file from the given URL. More... | |
KzbFile * | getKzbFile (string_view hostname, size_t index=0) const |
Get the kzb file construct corresponding to the given name. More... | |
void | reloadFromUrl (Resource *resource) |
Kanzi internally uses this function to reload a resource from a kzb file. More... | |
KzbFileDictionary::const_iterator | beginKzbFiles () const |
Returns the iterator to the beginning of loaded KZB files. More... | |
KzbFileDictionary::const_iterator | endKzbFiles () const |
Returns the iterator to the end of loaded KZB files. More... | |
Static Public Member Functions | |
static kzString | getResourcePathFromURL (kzString resourceURL) |
Kanzi internally uses this function to convert a resource URL to a resource path by dropping the protocol and project name from the path. More... | |
static kzString | getRelativePathFromAbsolutePath (kzString absolutePath) |
Kanzi internally uses this function to convert an absolute path to a node to a relative path by removing the screen name part of the path. More... | |
Friends | |
class | FinishingQueue |
class | Resource |
class | GPUResource |
class | PreviewPatcher |
Use the resource manager to access and use resources in kzb files.
The resource manager maintains kzb files and provides mechanisms to load resources from kzb files.
To access resources in a kzb file, use the kzb URL of the resource that you want to access. For example, the URL string "kzb://programmer_tutorial/Prefabs/Widget Item Prefab" refers to the resource called "Widget Item Prefab" inside the folder "Prefabs" in the kzb file of the "programmer_tutorial" project.
When you acquire a URL for the first time, the resource manager loads the resource and caches it. The next time you use the same URL, Kanzi does not load the resource again, but returns the previously loaded resource instead.
To acquire a single resource, use acquireResource:
Kanzi manages the lifetime of resources with shared pointers, but to cache resources, the resource manager maintains a shared pointer to each acquired resource. This means that Kanzi does not automatically release the memory used by resources, even if you are not using those resources.
To destroy resources and release the memory used up by those resources, use purge:
The resource manager uses worker threads to load multiple resources simultaneously and in the background, while the application is running. You can use Application::onConfigure to specify the number of loader threads. With loader threads you can load textures, meshes, and shaders. Kanzi uses the main thread to load all other types of resources.
You can decrease the loading time of resources by first collecting the URLs of all resources and loading multiple resources simultaneously. Kanzi does this automatically for the startup screen. If you are instantiating prefabs using the API, you can use collectResourceUrls to collect the URLs and acquireResourcesAsync to acquire the resources:
If you need the results immediately, you can use wait:
At application startup, Kanzi opens the kzb files that you specify in the application.cfg or in the configuration file specified by the Application::onConfigure. With the resource manager you can use addKzbFile to open additional kzb files at runtime:
Besides loading resources from kzb files, you can load resources from the file system. The resource manager supports the loading of these resource types from the file system:
Kanzi determines the type of the resource it creates from the file extension, not from the file contents. You have to ensure that the files use correct extensions.
To load resources from the file system, use the file:// protocol:
typedef shared_ptr<LoadTask> kanzi::ResourceManager::LoadTaskSharedPtr |
LoadTask shared pointer type.
typedef vector<LoadTaskSharedPtr> kanzi::ResourceManager::ResourceContainer |
Container type for load tasks.
typedef kzsException(* kanzi::ResourceManager::ProtocolHandler) (ResourceManager *resourceManager, string_view resourceURL, string_view protocol, string_view hostname, unsigned port, string_view path, void *userData, ResourceSharedPtr &out_resource, LoadTaskSharedPtr &out_loadTask) |
Type definition for the protocol handler of the load function.
The load function takes a resource URL and creates either a new resource or a load task that creates a new resource.
resourceManager | The resource manager. |
resourceURL | The full URL of the resource in the form of protocol://hostname[:port]/path. |
protocol | Extracted protocol part of the resource URL. |
hostname | Extracted hostname part of the resource URL. |
port | Extracted port part of the resource URL. This is 0 if the port is omitted from the URL. |
path | Extracted path part of the resource URL. |
userData | The extra protocol specific data object that was stored when the protocol handler was registered. |
out_resource | The loaded resource, or nullptr. |
out_loadTask | A load task for the resource, or nullptr. |
typedef function<void(ResourceManager*, string_view resourceURL, string_view protocol, string_view hostname, unsigned port, string_view path, void* userData, Resource* resource)> kanzi::ResourceManager::ProtocolResourceReloadFunction |
Type definition for the protocol handler of the reload function.
The reload function takes a resource URL and an existing resource, and reloads the resource.
typedef vector<pair<string, KzuBinaryDirectory*> > kanzi::ResourceManager::DirectoryContainer |
Type for the directory container.
typedef vector<pair<LoadTaskSharedPtr, ResourceLoaderThreadContext*> > kanzi::ResourceManager::FinishingQueueContainer |
Container type for the finishing queue. Used internally.
typedef unordered_set<string> kanzi::ResourceManager::UrlContainer |
Container type for URL set.
typedef function<void()> kanzi::ResourceManager::AsyncAcquireFinishedCallback |
Callback function type for acquire tasks.
typedef shared_ptr<AcquireTask> kanzi::ResourceManager::AcquireTaskSharedPtr |
AcquireTask shared pointer type.
typedef unique_ptr<KzbFile> kanzi::ResourceManager::KzbFilePtr |
Type for a smart pointer to a KZB file.
typedef map<string, vector<KzbFilePtr> > kanzi::ResourceManager::KzbFileDictionary |
Type for the KZB file container.
Resource manager memory strategy.
Enumerator | |
---|---|
KeepInMemory |
When a resource is no longer referenced, the resource manager keeps the resource in memory until you call purge(). |
OptimizeMemory |
When a resource is no longer referenced, the resource manager deletes the resource and frees the (CPU and GPU) memory used by the resource. |
|
explicit |
Constructor.
memoryManager | Memory manager to use. |
kanzi::ResourceManager::~ResourceManager | ( | ) |
Destructor.
void kanzi::ResourceManager::initializeLoaderThreads | ( | size_t | threadCount, |
size_t | maxPendingResources | ||
) |
Initializes the additional resource loader threads for the resource manager.
Do not call this function, because Kanzi automatically calls it.
threadCount | The number of loader threads. If 0, parallel loading is disabled. |
maxPendingResources | The maximum number of resources that can be processed by the loading threads at the same time. If set to 0, behaves as if set to threadCount + 1. |
void kanzi::ResourceManager::uninitializeLoaderThreads | ( | ) |
Stops and removes the loader threads. After the call, all loading happens in the main thread.
void kanzi::ResourceManager::setMaxPendingResources | ( | size_t | maxPendingResources | ) |
You can use this function to change the maximum number of resources that can be processed by the loading threads at the same time.
maxPendingResources | The maximum number of resources that can be processed by the loading threads at the same time. If set to 0, behaves as if set to threadCount + 1. |
void kanzi::ResourceManager::addDirectory | ( | KzuBinaryDirectory * | directory | ) |
Adds a binary directory to the resource manager to be used with the kzb protocol.
This transfers the ownership of the binary directory to the resource manager.
directory | The binary directory you want to add. |
KzuBinaryDirectory* kanzi::ResourceManager::mergeDirectory | ( | KzuBinaryDirectory * | directory | ) |
Merges a binary directory with another binary directory that has the same name and that already exists in the resource manager:
directory | The binary directory you want to merge. |
void kanzi::ResourceManager::removeDirectory | ( | KzuBinaryDirectory * | directory | ) |
Removes a binary directory from the resource manager.
directory | The binary directory you want to remove. |
void kanzi::ResourceManager::addKzbFile | ( | string_view | fileName | ) |
Opens a kzb file from the file system and adds it to the list of files.
If this function cannot open the file you pass to it or that file is not a kzb file, the function throws an exception.
fileName | The name of the file to open. |
void kanzi::ResourceManager::addKzbFile | ( | unique_ptr< KzbFile > | kzbFile | ) |
Adds a kzb file to the list of files.
kzbFile | File to add. |
void kanzi::ResourceManager::addKzbFile | ( | ConstByteSpan | data | ) |
Adds a memory block as a kzb file.
This function internally creates a kzb file by reading the memory block.
data | Data to add. The memory area must be readable as long as the resource manager is alive. |
unique_ptr<ReadOnlyMemoryFile> kanzi::ResourceManager::openFile | ( | string_view | url, |
KzbFile ** | kzbFile | ||
) |
Opens a handle to a resource file inside a kzb file.
You can use this handle to read data directly from the kzb file.
url | URL of the resource. | |
[out] | kzbFile | If the function finds the resource file, returns a pointer to the kzb file. |
KzuBinaryDirectory* kanzi::ResourceManager::getDirectory | ( | string_view | name | ) | const |
Gets the binary directory with the given name from the resource manager.
KzuBinaryDirectory* kanzi::ResourceManager::addDirectoryFromFile | ( | string_view | fileName | ) |
Adds a binary directory from a kzb file to the resource manager, which you can then use with the kzb protocol.
The resource manager keeps the ownership of the binary directory.
fileName | Path to the kzb file. Note that the filename can be different from the directory name stored in the kzb file. For example, file Programmer_tutorial.kzb can contain a directory named programmer_tutorial. |
KzuBinaryDirectory* kanzi::ResourceManager::mergeDirectoryFromFile | ( | string_view | fileName | ) |
Loads a binary directory from a kzb file and merges it with another binary directory with the same name that already exists in the resource manager.
fileName | The name of the kzb file from which to load the binary directory. |
|
inline |
Returns the iterator to the beginning of binary directories.
|
inline |
Returns the iterator to the end of binary directories.
void kanzi::ResourceManager::invalidateAllGPUResources | ( | ) |
Kanzi internally uses this function to set all the GPU resources to undeployed state when an application loses and recreates the GL context after a pause-resume event.
void kanzi::ResourceManager::getMemoryUsage | ( | size_t * | out_resourceCount, |
size_t * | out_cpuMemoryUsage, | ||
size_t * | out_gpuMemoryUsage | ||
) | const |
Calculates the memory usage summary for all resources.
out_resourceCount | The total number of resources. |
out_cpuMemoryUsage | Estimate for the total amount of bytes of CPU memory that the resources use. |
out_gpuMemoryUsage | Estimate for the total amount of bytes of GPU memory that the resources use. |
size_t kanzi::ResourceManager::getAcquireTaskCount | ( | ) | const |
Returns the number of acquire tasks that have been started with a call to acquireResourcesAsync and have not yet been completed.
Each acquire task can load multiple resources.
size_t kanzi::ResourceManager::getLoadQueueSize | ( | ) | const |
Returns the number of resource load tasks that are being processed.
This includes the load tasks that are waiting to be loaded and load tasks that are currently being loaded. This does not include the load tasks that are in the finishing queue.
Domain* kanzi::ResourceManager::getDomain | ( | ) | const |
Returns the domain.
void kanzi::ResourceManager::registerProtocolHandler | ( | kzString | protocol, |
ProtocolHandler | handler, | ||
ProtocolResourceReloadFunction | reloadFunction, | ||
void * | userData | ||
) |
Registers a protocol handler for loading resources specified with the given resource URL protocol (scheme name).
protocol | The protocol name. For example, "http". |
handler | The protocol loader function. Kanzi calls this function when you use a URL with the given protocol, and Kanzi does not find an existing resource with that URL. This loader function creates a resource. reloadFunction The protocol reloader function. Kanzi calls this function to recreate an existing resource. Kanzi uses this function only for GPU resources when an application loses GL context in a pause-resume event. |
userData | Extra data that you want to pass to the handler functions. |
void kanzi::ResourceManager::unregisterProtocolHandler | ( | kzString | protocol | ) |
Unregisters the protocol handler with the given resource URL protocol (scheme name).
bool kanzi::ResourceManager::supportsProtocolHandler | ( | kzString | protocol | ) | const |
Checks whether the given resource URL protocol (scheme name) is registered as a protocol handler for the resource manager.
protocol | The protocol to check. |
ResourceSharedPtr kanzi::ResourceManager::acquireResource | ( | string_view | url | ) |
Acquires a resource associated with the given URL.
If no resource is associated with the URL, tries to load the resource from the location specified by the URL. The URL specifies the location with a protocol and a protocol-specific path. If you already earlier acquired the resource at the given URL, this function returns a shared pointer to the already acquired resource.
The supported protocols are:
url | URL of the resource. |
ResourceSharedPtr kanzi::ResourceManager::tryAcquireResource | ( | string_view | url | ) |
Acquires a resource associated with the given URL, like acquireResource, but does not throw exceptions.
url | URL of the resource. |
|
inline |
Acquires a resource associated with the given URL and casts the resource to the given type.
If the type cast fails, the function returns nullptr.
url | URL of the resource. |
|
inline |
Acquires a resource associated with the given URL and casts the resource to the given type.
If the resource does not exist or the type cast fails, the function throws an exception.
url | URL of the resource. |
void kanzi::ResourceManager::registerResource | ( | string_view | url, |
ResourceSharedPtr | resource | ||
) |
Associates the given URL with the resource so that the next acquireResource with the URL returns the resource.
You can use this function to provide a URL to a resource that you created using the API.
url | URL of the resource. |
resource | The registered resource. |
void kanzi::ResourceManager::registerLoadTask | ( | string_view | url, |
LoadTaskSharedPtr | loadTask | ||
) |
Associates the given URL with the resource so that the next acquireResource with the URL completes the load task and returns the result.
url | URL of the resource. |
loadTask | A load task that creates the resource at the given URL. |
void kanzi::ResourceManager::unregisterResource | ( | string_view | url | ) |
Removes the association of the given URL to a resource or a load task.
You can use this function to force Kanzi to recreate a resource the next time you use this URL.
url | URL of the resource. |
ResourceSharedPtr kanzi::ResourceManager::acquireLoadedResource | ( | string_view | url | ) | const |
Acquires a resource associated with the given URL.
If no resource is associated with the URL, does not try to load the resource.
url | URL of the resource. |
BitmapImageUniquePtr kanzi::ResourceManager::loadImage | ( | string_view | url | ) | const |
Loads an image from the given URL.
KzcSpline* kanzi::ResourceManager::loadSpline | ( | string_view | url | ) | const |
Loads a spline from the given URL.
string kanzi::ResourceManager::getResourceURL | ( | const Resource & | resource | ) | const |
Tries to find a URL for the given resource.
This function loops over all resources, so it can take a long time to complete.
resource | The resource. |
Kanzi internally uses this function to convert a resource URL to a resource path by dropping the protocol and project name from the path.
For example, converts the URL "kzb://programmer_tutorial/Textures/bgr" to "Textures/bgr".
resourceURL | A resource URL. |
|
static |
Kanzi internally uses this function to convert an absolute path to a node to a relative path by removing the screen name part of the path.
For example, converts the path "Screen/RootPage/Viewport 2D" to "RootPage/Viewport 2D".
absolutePath | Absolute path to a node in the tree. |
void kanzi::ResourceManager::setDefaultMemoryStrategy | ( | MemoryStrategy | resourceReleaseStrategy | ) |
Sets the memory release strategy for new resources.
resourceReleaseStrategy | The new memory strategy. |
MemoryStrategy kanzi::ResourceManager::getDefaultMemoryStrategy | ( | ) | const |
Gets the memory release strategy.
void kanzi::ResourceManager::purge | ( | ) |
Deletes unreferenced resources.
You can use this function to free memory. Destroys all resources that are referenced only by the resource manager.
void kanzi::ResourceManager::update | ( | ) |
Processes resource manager load and deployment queues to progress the background tasks.
Kanzi calls this function once every frame.
|
inline |
Gets the finishing queue for asynchronous loading tasks.
You can use this to control the deployment strategy of the resources.
bool kanzi::ResourceManager::processDeploymentQueueItem | ( | ) |
Processes asynchronous loading tasks by deploying a single loaded GPU resource.
This function does not do anything if there are no active asynchronous loading tasks with loaded resources. Kanzi calls this function once every frame. Call this function periodically to ensure that asynchronous loading tasks are completed.
bool kanzi::ResourceManager::hasDeploymentTasks | ( | ) | const |
Tell if deployment queue is empty.
AcquireTaskSharedPtr kanzi::ResourceManager::acquireResourcesAsync | ( | const UrlContainer & | urls, |
AsyncAcquireFinishedCallback | callback | ||
) |
Creates a background task that loads and deploys all resources from a set of URLs.
After Kanzi loads and deploys all resources, the function calls the callback you provide.
urls | Set of URLs for resources that you want to load. |
callback | Callback function that this function calls when Kanzi loads all specified resources. |
void kanzi::ResourceManager::wait | ( | AcquireTask & | acquireTask | ) |
Blocks the execution until the async acquire task finishes and calls the callback of the task (unless it has been called already).
acquireTask | Acquire task created by acquireResourcesAsync. |
void kanzi::ResourceManager::deployGPUResources | ( | ) |
Kanzi internally uses this function to reload all GPU resources that have been invalidated by the pause-resume event.
void kanzi::ResourceManager::setDomain | ( | Domain * | domain | ) |
Kanzi internally uses this function to set the domain of the resource manager when it creates a resource manager.
KzcMemoryManager* kanzi::ResourceManager::getMemoryManager | ( | ) | const |
Returns the memory manager.
KzuBinaryFileInfo* kanzi::ResourceManager::getBinaryFileInfo | ( | string_view | url | ) | const |
Gets the kzb file information for a file from the given URL.
url | URL of the binary file. |
KzbFile* kanzi::ResourceManager::getKzbFile | ( | string_view | hostname, |
size_t | index = 0 |
||
) | const |
Get the kzb file construct corresponding to the given name.
hostname | Hostname of the kzb file. |
index | Index of the file for the given hostname, typically 0. Can be set to higher than 0 when a single hostname has multiple kzb files. |
void kanzi::ResourceManager::reloadFromUrl | ( | Resource * | resource | ) |
Kanzi internally uses this function to reload a resource from a kzb file.
resource | The reloaded resource. |
|
inline |
Returns the iterator to the beginning of loaded KZB files.
|
inline |
Returns the iterator to the end of loaded KZB files.
|
friend |
|
friend |
|
friend |
|
friend |